package com.inlycat.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.validation.constraints.Min;

import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * @author jarvan4dev@163.com
 * @since 2015年8月12日下午1:18:23
 * @category 用户的账户实体类
 */

//json转换的时候，用于过滤null字段
//@JsonInclude(Include.NON_NULL)
public class Account implements Serializable {

	private static final long serialVersionUID = 6890768212119856595L;

	/**
	 * 账户ID
	 */
	private Long id;
	
	/**
	 * 用户ID
	 */
	private Long userId;

	/**
	 * 当前账户余额
	 */
	@Min(value = 0, message = "{account.balance.min}")
	private Integer balance;

	/**
	 * 账户更新时间
	 */
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date time;

	/**
	 * 账户的用户信息，根据账户反向查询用户信息的时候需要
	 */
	private User user;

	/**
	 * 账户的流水信息
	 */
	private List<AccountRecord> accountRecords;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public Integer getBalance() {
		return balance;
	}

	public void setBalance(Integer balance) {
		this.balance = balance;
	}

	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public List<AccountRecord> getAccountRecords() {
		return accountRecords;
	}

	public void setAccountRecords(List<AccountRecord> accountRecords) {
		this.accountRecords = accountRecords;
	}

	@Override
	public String toString() {
		return "Account [id=" + id + ", balance=" + balance + ", time=" + time
				+ ", user=" + user + ", accountRecords=" + accountRecords + "]";
	}

}
